package com.xxx.store.controller;

import com.xxx.store.entity.Product;
import com.xxx.store.service.ProductService;
import com.xxx.store.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/products")
public class ProductController extends BaseController{
    @Autowired
    private ProductService productService;
    @RequestMapping("/hotList")
    public JsonResult<List<Product>> hotList(){
        List<Product> hotList = productService.findHotList();
        return new JsonResult<>(OK,hotList);
    }
    @RequestMapping("/details/{id}")
    public JsonResult<Product> details(@PathVariable("id") Integer id){
        Product product = productService.findProductDetail(id);
        return new JsonResult<>(OK,product);
    }
}
